using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Decisions.HL7.Message;
using DecisionsFramework;

namespace Decisions.HL7.Message
{
    public class SpecimenRoleAttribute:RuleAttribute
    {
        private Dictionary<HL7Version, string[]> validVersionCodes = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, string[]> validVersionDescriptions = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, HL7TableType> tableVersionTypes = new Dictionary<HL7Version, HL7TableType>();

        public SpecimenRoleAttribute()
        {
            // init the values for table version types
						tableVersionTypes[HL7Version.v24] = HL7TableType.User;
						tableVersionTypes[HL7Version.v25] = HL7TableType.User;
						tableVersionTypes[HL7Version.v251] = HL7TableType.User;
						tableVersionTypes[HL7Version.v26] = HL7TableType.User;
						tableVersionTypes[HL7Version.v27] = HL7TableType.User;
			
            
			// init the values for version codes
						validVersionCodes[HL7Version.v24] = new string[]{"P","Q","C","B","R"};
						validVersionCodes[HL7Version.v25] = new string[]{"P","Q","C","E","F","B","G","R","L","O","V"};
						validVersionCodes[HL7Version.v251] = new string[]{"B","C","E","F","G","L","O","P","Q","R","V"};
						validVersionCodes[HL7Version.v26] = new string[]{"B","C","E","F","G","L","O","P","Q","R","V"};
						validVersionCodes[HL7Version.v27] = new string[]{"B","C","E","F","G","L","O","P","Q","R","V"};
			
			// init the values for version descriptions
						validVersionDescriptions[HL7Version.v24] = new string[]{"Patient (default if blank component value)","Control specimen","Calibrator","Blind Sample","Replicate (of patient sample as a control)"};
						validVersionDescriptions[HL7Version.v25] = new string[]{"Patient (default if blank component value)","Control specimen","Calibrator","Electronic QC, used with manufactured reference providing signals that simulate QC results","Specimen used for testing proficiency of the organization performing the testing (Filler)","Blind Sample","Group (where a specimen consists of multiple individual elements that are not individually identified)","Replicate (of patient sample as a control)","Pool (aliquots of individual specimens combined to form a single specimen representing all of the components.)","Specimen used for testing Operator Proficiency","Verifying Calibrator, used for periodic calibration checks"};
						validVersionDescriptions[HL7Version.v251] = new string[]{"Blind Sample","Calibrator, used for initial setting of calibration","Electronic QC, used with manufactured reference providing signals that simulate QC results","Specimen used for testing proficiency of the organization performing the testing (Filler)","Group (where a specimen consists of multiple individual elements that are not individually identified)","Pool (aliquots of individual specimens combined to form a single specimen representing all of the components.)","Specimen used for testing Operator Proficiency","Patient","Control specimen","Replicate","Verifying Calibrator, used for periodic calibration checks"};
						validVersionDescriptions[HL7Version.v26] = new string[]{"Blind Sample","Calibrator, used for initial setting of calibration","Electronic QC, used with manufactured reference providing signals that simulate QC results","Specimen used for testing proficiency of the organization performing the testing (Filler)","Group (where a specimen consists of multiple individual elements that are not individually identified)","Pool (aliquots of individual specimens combined to form a single specimen representing all of the components.)","Specimen used for testing Operator Proficiency","Patient (default if blank component value)","Control specimen","Replicate (of patient sample as a control)","Verifying Calibrator, used for periodic calibration checks"};
						validVersionDescriptions[HL7Version.v27] = new string[]{"Blind Sample","Calibrator, used for initial setting of calibration","Electronic QC, used with manufactured reference providing signals that simulate QC results","Specimen used for testing proficiency of the organization performing the testing (Filler)","Group (where a specimen consists of multiple individual elements that are not individually identified)","Pool (aliquots of individual specimens combined to form a single specimen representing all of the components.)","Specimen used for testing Operator Proficiency","Patient (default if blank component value)","Control specimen","Replicate (of patient sample as a control)","Verifying Calibrator, used for periodic calibration checks"};
			            

        }

        
        public override ValidationIssue[] RunRule(string name, object owningObject, object value)
        {
            //todo: check if the value is valid in the current version
            //if the value is not valid in the current version, add it as a validation issue


            return new ValidationIssue[0];
        }
    }
}
